package main

import (
	"fmt"
	"strconv"
	"unsafe"
)

func GetYangHuiTriangleNextLine(inArr []int) []int {
	var out []int
	var i int
	arrLen := len(inArr)
	out = append(out, 1)
	if 0 == arrLen {
		return out
	}
	for i = 0; i < arrLen-1; i++ {
		out = append(out, inArr[i]+inArr[i+1])
	}
	out = append(out, 1)
	return out
}

func yangHuiSanJiao(rows int) {
	for i := 0; i < rows; i++ {
		number := 1
		for k := 0; k < rows-i; k++ {
			fmt.Print("  ")
		}
		for j := 0; j <= i; j++ {
			fmt.Printf("%5d", number)
			number = number * (i - j) / (j + 1)
		}
		fmt.Println()
	}
}

func main() {
	var nums []int
	var i int
	for i = 0; i < 10; i++ {
		nums = GetYangHuiTriangleNextLine(nums)
		fmt.Println(nums)
	}

	yangHuiSanJiao(12)

	var nameLen string = strTest("Jade")
	fmt.Println("name 长度为：" + nameLen)
}

func strTest(name string) string {
	const (
		a = "abc"
		b = len(a)
		c = unsafe.Sizeof(a)
		d = iota
		e = 2 << iota
	)

	arr := [...]int{2, 4, 33, 6}
	fmt.Println(arr)

	if c > d {
		fmt.Printf("c > d:%d\n", c)
	} else if c == d {
		fmt.Println("c == d")
	} else {
		fmt.Println("c < d")
	}

	fmt.Println(a, b, c, d, e, name)
	return strconv.Itoa(len(name))
}
